﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Web.Script.Serialization;

namespace Cstudy.Tools
{
    public class JsonHelper
    {
        public static string ToJson(object obj)
        {
            JavaScriptSerializer js = new JavaScriptSerializer();
            return js.Serialize(obj);
        }

        public static T ToEntity<T>(string json) where T : new()
        {
            JavaScriptSerializer js = new JavaScriptSerializer();
            T t = js.Deserialize<T>(json);
            return t;
        }
    }
}
